package com.easy.user.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easy.common.bean.ManagerBean;
import com.easy.common.bean.UserBean;
import com.easy.common.service.IManagerService;
import com.easy.common.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/manager")
@CrossOrigin
public class ManagerController {
    @Autowired
    IManagerService managerService;
    //管理员
    //添加管理员
    @PostMapping("/add")
    public Result addManager(@RequestBody ManagerBean manager){
        int result = managerService.addManager(manager);
        if(result >0 ){
            return Result.success("添加场地信息成功");
        }
        return Result.fail(400,"添加场地信息失败");
    }
    //查管理员
    @GetMapping("/all")
    public Result getAll(ManagerBean manager){
        Object venue_data = managerService.getAll(manager);
        return Result.success(venue_data);
    }
    //删除管理员
    @DeleteMapping("/del/{id}")
    public Result deleteManager(@PathVariable("id") Integer id){
        int result = managerService.deleteManager(id);
        if(result>0){
            return Result.success("删除管理员成功");
        }
        return Result.fail(400,"删除管理员失败");
    }
    //修改管理员
    @PutMapping("/update")
    public Result uploadManager(@RequestBody ManagerBean manager){
        int result = managerService.uploadManager(manager);
        if(result>0){
            return Result.success("修改管理员成功");
        }
        return Result.fail(400,"修改管理员失败");
    }
    //分页查询
    @GetMapping("/page")
    public Result getPage(ManagerBean  manager, Page<ManagerBean> page) {
        managerService.getPage(manager, page);
        return Result.success(page);
    }
}
